package com.suitsoft.bdms.entity.system;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;


import com.suitsoft.bdms.entity.IdEntity;
import com.suitsoft.bdms.entity.account.User;


/**
 * 单点登陆信息
 *@author Suine
 */
@Entity
@Table(name="BD_POIT_LOGIN")
public class PointEntity extends IdEntity{
	
	/** URL */
	private String url;
	/** 用户名 */
	private String username;
	/** 密码 */
	private String password;
	/** 最后操作人 */
	
	private User LastUser;
	/** 最后操作时间 */
	private Date lastDate;
	/** 系统名 */
	private String systemName;
	/** 最后同步人 */
	private User lastSyncUser;
	/** 最后同步时间 */
	private Date lastSyncDate;
	/** 定时执行时间  单位：分 */
	private Long timerMini;
	
	/** 子系统的应用 */
	private List<SubPointEntiry> subPoints = new ArrayList<SubPointEntiry>();
	@OneToMany(fetch = FetchType.LAZY,mappedBy="parent")
	@OrderBy("id")
	public List<SubPointEntiry> getSubPoints() {
		return subPoints;
	}
	@Transient
	public List<SubPointEntiry>getStudentSubPoint(){
		List<SubPointEntiry> list = new ArrayList<SubPointEntiry>();
		for(SubPointEntiry sp : this.getSubPoints()){
			if(sp.getType().trim().equals("学生")){
				list.add(sp);
			}
		}
		return list;
	}
	@Transient
	public List<SubPointEntiry>getTeacherSubPoint(){
		List<SubPointEntiry> list = new ArrayList<SubPointEntiry>();
		for(SubPointEntiry sp : this.getSubPoints()){
			if(sp.getType().trim().equals("")){
				list.add(sp);
			}
		}
		return list;
	}
	public PointEntity() {
		// TODO Auto-generated constructor stub
	}
	public void setSubPoints(List<SubPointEntiry> subPoints) {
		this.subPoints = subPoints;
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	public User getLastUser() {
		return LastUser;
	}
	public void setLastUser(User lastUser) {
		LastUser = lastUser;
	}
	public Date getLastDate() {
		return lastDate;
	}
	public void setLastDate(Date lastDate) {
		this.lastDate = lastDate;
	}
	public String getSystemName() {
		return systemName;
	}
	public void setSystemName(String systemName) {
		this.systemName = systemName;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	public User getLastSyncUser() {
		return lastSyncUser;
	}
	public void setLastSyncUser(User lastSyncUser) {
		this.lastSyncUser = lastSyncUser;
	}
	public Date getLastSyncDate() {
		return lastSyncDate;
	}
	public void setLastSyncDate(Date lastSyncDate) {
		this.lastSyncDate = lastSyncDate;
	}
	public Long getTimerMini() {
		return timerMini;
	}
	public void setTimerMini(Long timerMini) {
		this.timerMini = timerMini;
	}
}

